<template>
	<div class="std-sew">

		<div>
			<label>{{ $t('route.Normal_Hours') }}</label>
			<div></div>
			<button><img /><label>{{ $t('route.Details_of_working_hours') }}</label></button>
		</div>


		<div v-loading="loading">
			<div>
				<el-cascader v-model="query.workLine" size="default" class="width210px"
					:placeholder="$t('route.Please_select_a_group')" :options="proLineOptions" @change="getStdSewList" />


				<div class="div-handle-right">
					<el-button @click="handlePageChange(1)">{{ $t('route.search') }}</el-button>
					<input v-model="query.search" :placeholder="$t('route.Name1')" />
				</div>
			</div>

			<el-table class="table" :data="stdSewList" style="width: 100%">
				<el-table-column prop="username" :label="$t('route.Name2')" width="160" />
				<el-table-column prop="nickname" :label="$t('route.full_name')" width="160" />
				<el-table-column :label="$t('route.Time6')" width="160">
					<template #default="scope">
						<div v-for="item of scope.row.craftList">
							{{ item.mono }}
						</div>
					</template>
				</el-table-column>
				<el-table-column :label="$t('route.Operation_No')" width="160">
					<template #default="scope">
						<div v-for="item of scope.row.craftList">
							{{ item.craftCode }}
						</div>
					</template>
				</el-table-column>
				<el-table-column :label="$t('route.Process_name')">
					<template #default="scope">
						<div v-for="item of scope.row.craftList">
							{{ item.craftName }}
						</div>
					</template>
				</el-table-column>
				<el-table-column :label="$t('route.Device')" width="300">
					<template #default="scope">
						<div class="table-item" v-for="item of scope.row.deviceList">
							{{ item.kind }}，{{ item.noseCode }}<label :style="{ color: item.online ? '#0F0' : '#f00' }"
								style="margin-left:10px">{{ item.online ? $t('route.Line1') : $t('route.Line2') }}</label>
						</div>
					</template>
				</el-table-column>
				<el-table-column :label="$t('route.operate')" width="200">
					<template #default="scope">
						<div class="table-item" v-for="item of scope.row.deviceList">
							<el-button @click="jumpPage('monitor-5', item, scope.row)">{{$t('route.Sewing_band')}}</el-button>
						</div>
					</template>
				</el-table-column>
			</el-table>

			<div class="pagination">
				<el-pagination style="float: right;" background @current-change="handlePageChange"
					:current-page="query.pageNum" :page-size="query.pageSize" layout="total, prev, pager, next"
					:total="query.total"></el-pagination>
			</div>


		</div>
	</div>
</template>

<script>
import http from "../../js/http/http.js";
import api from "../../js/http/api.js";
export default {
	data() {
		return {
			stdSewList: [],
			proLineOptions: [],
			query: {
				workLine: [],
				pageNum: 1,
				pageSize: 5,
				total: 0,
				search: null
			},
			loading: false

		};
	},
	methods: {
		jumpPage(pageName, param1, param2) {
			this.$router.push({
				name: pageName,
				params: {
					device: JSON.stringify(param1),
					stdSewInfo: JSON.stringify(param2)
				}
			})
		},
		getStdSewList() {
			this.loading = true;
			this.$store.commit("setWorkshop", this.query.workLine[0]);
			this.$store.commit("setProLine", this.query.workLine[1]);
			http.post(api.GET_STD_SEW_LIST, {
				adminId: this.$store.state.user.id,
				workshop: this.query.workLine[0],
				proLine: this.query.workLine[1],
				pageNum: this.query.pageNum,
				pageSize: this.query.pageSize,
				search: this.query.search,
			}, data => {
				this.stdSewList = data.data.stdSewList;
				this.query.total = data.data.total;
				this.loading = false;
			}, () => {
				this.loading = false;
			})
		},

		getPorLineRow() {
			http.post(api.GET_POR_LINE_ROW, {
				adminId: this.$store.state.user.id,
			}, data => {
				this.proLineOptions = data.data;
			});
		},
		handlePageChange(pageNum) {
			this.query.pageNum = pageNum;
			this.getStdSewList();

		}
	},
	created() {
		this.query.workLine = [this.$store.state.workshop, this.$store.state.proLine];
		this.getPorLineRow();
		this.getStdSewList();
	},
};
</script>
<style lang="scss" scoped>
.std-sew {
	color: #444444;
	font-size: 18px;
	padding-right: 20px;
	height: calc(100vh - 100px);
	// overflow: scroll;
	scrollbar-width: none;
	/* firefox */
	-ms-overflow-style: none;
	/* IE 10+ */
	overflow-x: hidden;
	overflow-y: auto;

	>div:nth-of-type(1) {
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-top: 20px;
		background-color: #ffffff;
		padding: 20px;
		border-radius: 5px;

		>label:nth-of-type(1) {
			font-weight: 600;
		}

		>div:nth-of-type(1) {
			width: 1px;
			background-color: #cccccc;
			height: 15px;
			margin: 0px 20px;
		}

		>button:nth-of-type(1) {
			background-image: url(../../assets/img/customer-1.png);
			background-repeat: no-repeat;
			background-size: 100% 100%;
			padding: 5px 10px;
			border: 0px;
			display: flex;
			color: #ffffff;
			flex-direction: row;
			align-items: center;
			font-weight: 800;

			>img {
				margin-right: 7px;
				width: 15px;
				height: 15px;
				content: url(../../assets/img/customer-2.png);
			}
		}
	}

	>div:nth-of-type(2) {
		display: flex;
		flex-direction: column;
		margin-top: 20px;
		background-color: #ffffff;
		padding: 20px;
		border-radius: 5px;


		>div:nth-of-type(1) {
			display: flex;
			flex-direction: row;
			align-items: center;

			.div-handle-right {
				flex: 1;
				flex-direction: row-reverse;
				text-align: right;
				display: flex;
				align-items: center;

				>input:nth-of-type(1) {
					border: 1px solid #eeeeee;
					font-size: 15px;
					width: 150px;
					padding: 5px 8px;
					outline: none;
				}

				>button {
					color: #A866FF;
					margin-left: 10px;
					padding: 4px 20px;
				}
			}
		}

		.table {
			margin-top: 20px;
			width: 100%;

			.table-item {
				margin: 10px 0px;
			}
		}

	}

	.select {
		width: 120px;
		margin-top: 10px;
	}

	.echart {
		height: 150px;
		width: 100%;
	}

}
</style>
